package com.qst.crop.controller;

import com.qst.crop.common.Result;
import com.qst.crop.pojo.User;
import com.qst.crop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.DigestUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@Validated
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping("/login")
    public Result<String> login(String username,String password) {
        User loginUser = userService.findByUsername(username);
        if (loginUser == null) {
            return Result.error("该用户不存在");
        }

        if (DigestUtils.md5DigestAsHex(password.getBytes()).equals(loginUser.getPassword())) {

        }

        return Result.error("密码错误");
    }
}
